home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11184 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  46 lines

  1. Path: fred.net!news
  2. From: bitmask@bigdog.fred.net (Scott Allen)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: STRTOL, STRTUL,STRTOD functions
  5. Date: Tue, 19 Mar 1996 15:34:36 GMT
  6. Organization: FredNet - Frederick, Md.
  7. Message-ID: <314ed2d3.110217@news.fred.net>
  8. References: <4ifjao$j5c@news1.h1.usa.pipeline.com>
  9. NNTP-Posting-Host: bitmask.fred.net
  10. X-Newsreader: Forte Agent .99d/32.168
  11.  
  12. fredrics@usa.pipeline.com(Fredric Smith) wrote:
  13.  
  14. >I cannot find sample pieces of code for these..would appreciate some
  15. >help..if someone can 
  16.  
  17.  
  18.  
  19. int main(void)
  20. {
  21.    char *string = "87654321", *endptr;
  22.    long lnumber;
  23.  
  24.   /* strtol converts string to long integer  */
  25.   /* strtoul converts a string to an unsigned long */
  26.   /* strtod converts a string to a double */
  27.  
  28.   /*  *endptr will point to the character that stopped the scan */
  29.  
  30.  
  31.    lnumber = strtol(string, &endptr, 10);
  32.  
  33.    printf("string = %s  long = %ld\n", string, lnumber);
  34.  
  35.    return 0;
  36. }
  37.  
  38.  
  39. Hope this helps, 
  40.  
  41. --
  42.        Scott Allen             
  43.   bitmask@bigdog.fred.net      
  44.     Hagerstown, MD USA         
  45.